<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {
            name: 123,
            password: 123,
            'my-name': 'dcj',

            drink: function () {
                alert("喝水")
            }
        }

        alert(obj.name)
        alert(obj['name'])
        alert(obj['my-name'])
        obj.drink()


        // 遍历对象
        for (let key in obj) {
            alert(obj[k])
        }

    </script>
</body>

</html>